window.onload = function () {
    const $window = $('.scroll')
    const win_height_padded = $window.height() //视口
    $window.on('scroll', revealOnScroll)
    const moveList = $(".move:not(.animated)")
    revealOnScroll()
    function revealOnScroll() {
        const scrolled = $window.scrollTop()
        //设置导航颜色
        if (scrolled > 5) {
            if ($('header').css('background-color') === 'rgba(0, 0, 0, 0)') {
                $('header').css('background-color', '#1f2738')
            }
        } else {
            $('header').css('background', 'rgba(0,0,0,0)')
        }
        moveList.each(function () {
            const $this = $(this)
            const offsetTop = $this.offset().top
            if (offsetTop <= win_height_padded) {
                // console.log(this)
                if ($this.data('timeout')) {
                    window.setTimeout(function () {
                        $this.addClass('animated ' + $this.data('animation')).css('visibility', 'visible')
                    }, parseInt($this.data('timeout'), 10));
                }
                else {
                    $this.addClass('animated ' + $this.data('animation'))
                }
            }
        })
    }
}